{include file="public/header" /}


<div class="page">
    <div class="fixed-empty"></div>
    <form id="post_form" method="post" name="form1" action="{url('Refund/add')}">
        <table class="ds-default-table">
            <tbody>
            <tr class="noborder">
                <td style="width: 500px;" class="required"><label class="validation" for="name">发票类型名称:</label>
                     <input style="margin-left: 104px;" id="name" name="name" value="" class="txt" type="text">
                </td>
                <td class="vatop tips"></td>
            </tr>
<!--             <tr class="noborder">
                <td class="vatop rowform">
                  <input id="name" name="name" value="" class="txt" type="text">
                </td>
                <td class="vatop tips"></td>
            </tr> -->
            <tr>
                <td style="width: 500px;" class="required"><label class="validation" for="sort">类型:</label>
                  <select style="margin-left: 154px;" name="type" id="type">
                        <option value="1">纸质版</option>
                        <option value="2">电子版</option>
                        <option value="3">全部</option>
                    </select>
                </td>
            </tr>
<!--             <tr class="noborder">
                <td class="vatop rowform">
                    <select name="type" id="type">
                        <option value="1">纸质版</option>
                        <option value="2">电子版</option>
                        <option value="3">全部</option>
                    </select>
                </td>
                <td class="vatop tips"></td> -->
            <!-- </tr> -->
             <tr>
                <td style="width: 500px;" class="required"><label class="validation" for="sort">开票类型:</label>
                  <select style="margin-left: 127px;" name="billing_type" id="billing_type">
                        <option value="1">个人</option>
                        <option value="2">企业</option>
                        <option value="3">全部</option>
                    </select>
                </td>
            </tr>
<!--             <tr class="noborder">
                <td class="vatop rowform">
                    <select name="billing_type" id="billing_type">
                        <option value="1">个人</option>
                        <option value="2">企业</option>
                        <option value="3">全部</option>
                    </select>
                </td>
                <td class="vatop tips"></td>
            </tr> -->
            <tr>
                <td style="width: 500px;" class="required"><label class="validation"
                                                        for="sort">{$Think.lang.ds_sort}:</label>

                   <input style="margin-left: 152px;" type="text" value="100" name="sort" id="sort"
                                                 class="txt"></td>

                </td>
                <td class="vatop tips"></td>
            </tr>
<!--             <tr class="noborder">
                <td class="vatop rowform"><input type="text" value="100" name="sort" id="sort"
                                                 class="txt"></td>
                <td class="vatop tips"></td>
            </tr> -->

            <tr class="noborder">
                <td class="vatop rowform" style="height: 30px;">
                    <label class="validation">是否启用：</label>
                    <div class="onoff" style="margin-top: -18px;
margin-left: 133px;">
                        <label style="margin-left: 69px;" for="site_state1"
                               class="cb-enable <?php if(isset($t_info) && $t_info['status']==1){?> selected <?php }else if(!isset($t_info)){echo 'selected';}?>">{$Think.lang.ds_open}</label>
                        <label for="site_state0"
                               class="cb-disable <?php if(isset($t_info) && $t_info['status']==0){?> selected <?php }?>">{$Think.lang.ds_close}</label>
                        <input id="site_state1" name="status" value="1"
                               type="radio" <?php if(isset($t_info) && $t_info['status']==1){?>
                        checked="checked"<?php }else if(!isset($t_info)){?> checked="checked" <?php }?>  >
                        <input id="site_state0" name="status" value="0"
                               type="radio" <?php if(isset($t_info) && $t_info['status']==0){?>
                        checked="checked"<?php }?>  >
                    </div>
                </td>
            </tr>
            </tbody>
            <tfoot>
            <tr class="tfoot">
                <td colspan="15"><input style="line-height: 2px;" class="btn" type="submit" value="{$Think.lang.ds_submit}"/></td>
            </tr>
            </tfoot>
        </table>
    </form>
</div>
<script>
    //按钮先执行验证再提交表单
    $(document).ready(function () {
        $("#post_form").validate({
            errorPlacement: function (error, element) {
                error.appendTo(element.parent().parent().prev().find('td:first'));
            },
            rules: {
                name: {
                    required: true,
                    remote   : {
                        url :"{:url('Brand/ajax','branch=check_invoice_type_name')}",
                        type:'get',
                        data:{
                            brand_name : function(){
                                return $('#name').val();
                            },
                        }
                    }
                },
                sort: {
                    required: true,
                    digits: true,
                    range: [0, 255]
                }
            },
            messages: {
                name: {
                    required: "不能为空",
                    remote   : '发票类型名称不可以重复哦~'
                },
                sort: {
                    required: "不能为空",
                    digits: "{$Think.lang.reason_sort_digits}",
                    range: '{$Think.lang.reason_sort_tips}'
                }
            }
        });

        /*  $("form").submit(function (e) {
              var res = $("#goods_class_form").valid();
              if (res) {
                  var url = $('form').attr('action');
                  $.ajax({
                      type: "POST",
                      url: url,
                      data: $('#goods_class_form').serialize(),// 你的formid
                      error: function (request) {
                          alert("Connection error");
                      },
                      success: function (result) {
                          if (result.code == 0) {
                              layer.msg(result.msg);
                              location.href = result.url;
                              return false;
                          } else {
                              layer.msg(result.msg);
                              location.href = result.url;
                              return false;
                              s

                          }
                      }
                  });
                  return false;


              }

          });*/


    });

</script>
